package com.funny.stock.user.vo;

/**
 * @author pengl
 * @date 2020/8/7
 */
public enum LoginModeEnum {

    USER_LOGIN("user_login",1),
    WORK_WX_QR_CODE("workwx_code",2),
    WORK_WX_OAUTH("workwx_oauth",3),
    PHONE_CODE("phone_code",4);

    String key;
    int type;

    LoginModeEnum(String key, int type){
        this.key = key;
        this.type = type;
    }

    public int getType() {
        return type;
    }

    public String getKey() {
        return key;
    }


    public static LoginModeEnum ofType(int type){
        LoginModeEnum[] values = values();
        for (int i = 0; i < values.length; i++) {
            if(values[i].getType() == type){
                return values[i];
            }
        }

        return null;
    }


    public static LoginModeEnum ofKey(String key){
        LoginModeEnum[] values = values();
        for (int i = 0; i < values.length; i++) {
            if(values[i].getKey().equals(key)){
                return values[i];
            }
        }

        return null;
    }


}
